package reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Scanner;


/**
 * 类对象
 */
public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
//        Class cls=String.class;
//        Class cls= ArrayList.class;
//        Class cls=Class.forName("java.util.ArrayList");
        Scanner scanner=new Scanner(System.in);
//        java.lang.String;
//        java.util.ArrayList;
//        java.util.HashMap
//        java.io.FileInputStream
        System.out.println("请输入类名");
        String className=scanner.nextLine();
        Class cls=Class.forName(className);

        String name=cls.getName();
        System.out.println(name);
        name=cls.getSimpleName();
        System.out.println(name);

        Package pack=cls.getPackage();
        String packName=pack.getName();
        System.out.println("包名"+packName);
        Method[]methods=cls.getMethods();
        System.out.println("一共"+methods.length+"个方法");
        for(Method method:methods){
            System.out.println(method.getName());
        }
    }
}
